package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.MallOrderRefundStatusLog;
import com.sc.nft.mapper.MallOrderRefundStatusLogMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * 售后单操作记录表(sc_mall_order_refund_status_log)数据DAO
 *
 * @author liGen
 * @version 1.0
 * @date 2023/11/23 2:10 下午
 */
@Slf4j
@Repository
public class MallOrderRefundStatusLogDao extends ServiceImpl<MallOrderRefundStatusLogMapper, MallOrderRefundStatusLog> {

    public List<MallOrderRefundStatusLog> getListByOrderRefundId(Long orderRefundId) {
        LambdaQueryWrapper<MallOrderRefundStatusLog> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(MallOrderRefundStatusLog::getOrderRefundId, orderRefundId);
        wrapper.orderByDesc(MallOrderRefundStatusLog::getId);
        return list(wrapper);
    }

    public MallOrderRefundStatusLog getByOrderIdAndChangeType(Long orderRefundId,String changeType) {
        LambdaQueryWrapper<MallOrderRefundStatusLog> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(MallOrderRefundStatusLog::getOrderRefundId, orderRefundId);
        wrapper.eq(MallOrderRefundStatusLog::getChangeType, changeType);
        return baseMapper.selectOne(wrapper);
    }
}